#ifndef SERVO_H
#define SERVO_H

#include <stdio.h>   /* Standard input/output definitions */
#include <stdlib.h>
#include <time.h>
#include <string.h>  /* String function definitions */
#include <unistd.h>  /* UNIX standard function definitions */
#include <fcntl.h>   /* File control definitions */
#include <errno.h>   /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */

class Servo
{
  public:
    Servo();
    ~Servo();
    void toAngle(double);
    void incUp();
    void incDown();
  
  private:
    void put(int servo, int angle);   // Moves servo (0-5) to angle (500-5500)
    void waitMS (int ms); // This allows for a set system instruction pause. Note: 1000ms = 1 sec.
    void close_port(int, char[]);
    void config_port(int);
    int open_port(char[]);
    
    typedef unsigned int DWORD;
    
    double curAngle;
    
    int mainfd;   /* File descriptor for the port */
    char chout;
    int min, 
        max, 
        step; // Decrease step size for finer control.

    bool foundServo;

};

#endif
